package com.frxuexi.mdm2204.demo

import android.util.Log
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountCircle
import androidx.compose.material.icons.filled.CheckCircle
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import com.frxuexi.mdm2204.R

@Preview
@Composable
fun Demo02() {
    //声明一个状态可变的变量，用于界面重组
    var name by remember {
        mutableStateOf("")
    }

    var pass by remember {
        mutableStateOf("")
    }

    /*Column(modifier = Modifier
        .fillMaxSize()
        .padding(20.dp), verticalArrangement = Arrangement.spacedBy(20.dp), horizontalAlignment = Alignment.CenterHorizontally) {
        Spacer(modifier = Modifier.height(100.dp))
        TextField(
            value = name, onValueChange = { name = it },
            label = { Text(text = "用户名") },
            leadingIcon = {
                Icon(
                    imageVector = Icons.Default.AccountCircle,
                    contentDescription = ""
                )
            },
            trailingIcon = {
                Button(onClick = {  }) {
                    Text(text = "发送验证码")
                }
            },
            visualTransformation = PasswordVisualTransformation(),//密文
            modifier = Modifier.fillMaxWidth()
        )
        //外边距
//        Spacer(modifier = Modifier.height(10.dp))
        OutlinedTextField(value = pass, onValueChange = {pass=it},label = { Text(text = "密码") },
            modifier = Modifier.fillMaxWidth())
        Button(modifier = Modifier.fillMaxWidth(),onClick = { *//*TODO*//* }) {
            Text(text = "登录")
        }

    }*/

    /*Column(Modifier.fillMaxHeight(), verticalArrangement = Arrangement.SpaceEvenly) {
        Text(text = "aa", modifier = Modifier.background(Color.Gray))
        Text(text = "bb")
        Text(text = "cc")
        Text(text = "dd")
    }*/

    /*Row(modifier = Modifier.fillMaxSize(), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Center) {
        TextField(
            value = name, onValueChange = { name = it },
            label = { Text(text = "用户名") },
            leadingIcon = {
                Icon(
                    imageVector = Icons.Default.AccountCircle,
                    contentDescription = ""
                )
            },
            trailingIcon = {
                Button(onClick = { *//*TODO*//* }) {
                    Text(text = "发送验证码")
                }
            },
            visualTransformation = PasswordVisualTransformation()//密文
        )*/
       /* //外边距
        Spacer(modifier = Modifier.width(10.dp))
        OutlinedTextField(value = pass, onValueChange = {pass=it},label = { Text(text = "密码") })*/
   // }



    Column(Modifier.fillMaxWidth()) {
        Text(
            text = "aa",
            modifier = Modifier
                .size(50.dp, 30.dp)
//                .size(DpSize(50.dp,30.dp))
                .padding(10.dp)
                .background(Color.Gray, RoundedCornerShape(10.dp))
                .padding(10.dp)
//                .weight(2f)
        )
        Text(text = "bb",
            textAlign = TextAlign.Center,
            modifier = Modifier

                .width(100.dp)
                .border(1.dp, Color.Cyan, RoundedCornerShape(10.dp,10.dp))//边框
                .background(Color.Gray, RoundedCornerShape(10.dp,10.dp))
                .alpha(0.2f)//透明度
//                .weight(1f)
        )
    }
}